const state = {
  userName: "",
  isLogin: false,
  token: "",
  rights: []
}

const mutations = {
  login(state, data) {
    state.userName = data.userName;
    state.isLogin = true;
    state.rights = data.menus;
    state.token = data.token;
    sessionStorage.token = data.token
  },
  logout(state) {
    state.userName = "",
      state.isLogin = false,
      state.rights = [],
      state.token = "",
      sessionStorage.removeItem('token')
  },
  update(state,value){
    state.rights = value;
  }
}

export default {
  state,
  mutations
}
